package io.alvin.jframework.plugin.security;

import io.alvin.jframework.helper.ConfigHelper;
import io.alvin.jframework.util.ReflectionUtil;
import sun.security.krb5.Config;

/**
 * 提供一系列静态方法，获取security.properties文件中的配置项
 *
 * Created by Alvin on 2017/7/15.
 */
public final class SecurityConfig {

    public static String getRealms() {
        return ConfigHelper.getString(SecurityConstant.REALMS);
    }

    public static Security getSecurity() {
        String className = ConfigHelper.getString(SecurityConstant.SECURITY);
        return (Security) ReflectionUtil.newInstance(className);
    }

    public static String getJdbcAuthcQuery() {
        return ConfigHelper.getString(SecurityConstant.JDBC_AUTHC_QUERY);
    }

    public static String getJdbcRolesQuery() {
        return ConfigHelper.getString(SecurityConstant.JDBC_ROLES_QUERY);
    }

    public static String getJdbcPermissionQuery() {
        return ConfigHelper.getString(SecurityConstant.JDBC_PERMISSIONS_QUERY);
    }

    public static boolean isCacheable() {
        return ConfigHelper.getBoolean(SecurityConstant.CACHEABLE);
    }
}
